<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>淡入效果的实现</title>
</head>
<body>
<div id="change" class="change">
    <h1 style="opacity: 0">Hello, World!</h1>
</div>

<script>
    let element = document.querySelector("h1");

    let count = 0
    let opacity = 0

    let interval = setInterval(
        () => {
            count += 1
            if (count === 100) {
                clearInterval(interval)
            } else {
                opacity += 0.01
                element.style.opacity = opacity
            }
        },
        100
    );
</script>
</body>
</html>